<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller{
	public function index(){
		$this->display();
	}
	function check(){
		$user =new \Think\Model('User');
		
		//接收数据
		$username = $_POST['username'];
		$password = $_POST['password'];
		
		//查询and防止sql注入
		$rs = $user->where("username='%s' and password='%s'",array($username,$password))
					->find();
		
		if($rs){
			$this->success('登陆成功',U('Index/index'));
		}else{
			$this->error('登录失败',U('Login/index'));
		}
	}
}
